A Circular Navigation System [Part 2]
by Jim Ubersetzig
This article was published in the October 1999 issue of the Robot Builder.
This article is a follow-up to "A Circular Navigation System [Part 1]"
Introduction
Have you ever wanted your robot to navigate accurately? Reliably moving to locations within a room is difficult for most robots. Usually they are not aware of their location. In this series of articles, I will show you how to solve the problem for indoor robots.
Part one was the theory document, and you should refer to it when you have questions about the mathematics (see Sept 99 issue of the "Robot Builder"). This month we will build the sensor assembly and get it working.
Parts and Cost
You will need these parts. Costs given are approximate. (editor's note: these are 1999 prizes)
Note: To load the software in this article into the Basic Stamp, you need a PC. The stamp also uses the PC to display test
results.
Skills Required
You will need certain minimum skills to complete the device described in this article:
- Soldering, electronic grade.
- Cutting plastic sheet.
- Safety skills to avoid injuries.
- Drilling holes.
Building the Sensor Head
Begin by finding a packing box and cut off a piece of corregated cardboard. Photocopy figure 1 and glue it to the cardboard. The photocopied figure must be 1-9/16 inch square. Adjust the photocopy machine until you achieve this size.
Using the glued paper pattern, trim the cardboard to proper size. Completely cover the other side of the cardboard with mounting tape, leaving the cover film in place. Cut a slot 1/16 inch wide where indicated and punch 6 holes using a needle for the emitter and collector leads of the phototransistors. Next remove the cover film from the mounting tape. Be careful to avoid getting fingerprints on the exposed sticky tape. Insert the wires of the laser module through the slot and press it firmly in place
on the sticky tape. Use figure 2 to identify the base wire on the phototransistors. Cut off the base wire.
Use figure 3 to determine the orientation of the tab for the three phototransistors. This figure shows the sticky tape and the components that are stuck to the tape. After sliding the wires through the holes, press all phototransistors firmly into the sticky tape.
Prepare the 35 mm film can by removing the lid and cutting off the bottom. Firmly press the rim of the film can into the sticky tape. Make sure that the laser is centered inside the film can. Bend a paper clip or a resistor lead into a circle and solder to the outer leads of all three phototransistors. Also solder the black wire of the laser module to this connection. Bend another resistor lead in a smaller circle and solder it to the inner lead of all the phototransistors.
Prepare a cable of three insulated stranded wires. Attach the cable to the cardboard with mounting tape. Wire the cable per figure 4.
Testing the Sensor Head
Connect a regulated 5 volt power supply to the red and black wires of the sensor head. DO NOT look directly at the laser. You should see a dot of red light on the wall. If not, check the wiring.
Connect a 10K ohm resistor between the red and white wires. Connect a voltmeter between the black and white wires. Tape a retroreflector to the wall. You should see a drop in the voltage when the laser spot hits the retroreflector. If not, check the wiring - the phototransistor emitters should be grounded to the black wire, the collectors should go to the white wire. make sure that the optical axis of the laser and all phototransistors point in the same direction.
Adding the Servos
Turn the disk on both servos to the center of its range of motion. Mark these so you can return them to the center position if they accidently move. Put mounting tape on the top of the disks and on the bottoms of both servos. Determine the balance
point of the sensor head and stick the side of the film can to the disk of a servo. The balance is important to prevent the sensor head from wobblingas it rotates.
Now find the center of balance of the assemby (servo and sensor head) and center it as you stick it to the tape on the disk of the other servo. Attach wiring as shown in figure 5. The wire lengths stated are critical to allow one full rotation of the sensor
head.
Adding the Electronics
Now install the rest of the parts and wires on a piece of perforated board. To save time - the author substituted a stamp 2 carrier board for the perforated board. The carrier board already has a socket for the Basic Stamp 2, the connector for your desktop PC and also has clips for the 9 volt battery. Using perforated board is less expensive. Wire the remaining parts per the schematic diagram in figure 6.
Note that the three pin headers are for plugging in the two servos. It's wise to mark the polarity of these to avoid plugging the servos in backwards. The laser power switch turns off the laser. When your sensor head is down near the floor, this minimizes the chance of annoying people with the laser. If you place the sensor head on a table, turn the laser power switch off, because the moving laser beam annoys people.
Theory of Operation
For a complete description of the theory of operation see the author's 1993 theory paper (reprinted in the Sept 99 issue of the "Robot Builder")
Alignment Procedure
On your PC type stamp2 <enter> and the stamp development system will come up. If you don't have this file ( stamp2.exe approx 15K bytes ), it's a free download from the parallax web site. It also comes with the developer's kit, along with the cable. If you don't have the cable, instructions for building one are on the web site.
On your PC you should see a screen for editing software. For servo alignment type in this software, then ALT-R to load and run it.
angle var word
angle = 800
loop: pulsout 1, angle: pause 18: goto loop
Change the angle to other numbers and ALT-R to see the resulting rotation of the sensor head. Keep trying other numbers until you have determined the exact limits of rotation of the sensor assembly. Both servos should turn to achieve slightly more
than one complete rotation of the sensor head. Use the information to correct the values for cw_limit and ccw_limit in the main software listing.
Next clear the PC screen and type in the main software listing (see above). Press ALT-S to save the software in a file. Type in a suitable file name, then <enter>.
Tape some retroreflectors to nearby objects. Delete the ' mark at the beginning of the ' debug ? reflection ' statement. Run the software with ALT-R. The idea here is to look for:
1) The average of the higher numbers.
2) The low number when the laser beam strikes a retroreflector target.
You can pause the display with the space bar to make this process easier. Once you find these numbers, use them to update
the values in the software for threshold and thresholdh. Replace ' mark at the beginning of the ' debug ? reflection ' statement.
Press ALT-S to save the software in a file. Type in a suitable file name, then <enter>.
Demonstration
Place three retroreflective targets where the laser beam will strike them. Press ALT-R on the PC.
After the laser sweeps in a complete circle, you should see a report on the PC display screen. Hit_index should be three (the number of targets found) and hit(0), hit(1) and hit(2) will be the measured angles to those targets. Examine the software carefully and note: the software takes hundreds of readings from the sensor head - but saves only those few sensor readings
which have meaning. This illustrates an important principle of robotics: Identify useless data as early as possible.
Jim Ubersetzig (jim.ubersetzig@lmco.com)
Note: This construction article describes the project demonstrated by the author at the April, 99 RSSC meeting.
The next article in this series is: "A Circular Navigation System [Part 3]"
' Software to locate three wall mounted retroreflective targets
' and to measure the angle to each one. Software runs on a
' Stamp 2.
' By Jim Ubersetzig
' April 99
' I/O pins
sensor con 6
servo con 1
' Variables and Constants
reflection var word ' reading from the phototransistors.
Threshold con 1500 ' greater than this is past target
thresholdh con 700 ' less than this means target is found.
lit var bit ' 1 -> reflection has been seen.
Angle var word ' current angle of the sensor assembly.
ccw_limit con 410 ' counter clockwise limit of rotation.
cw_limit con 1270 ' clockwise limit of sensor rotation.
Hit var byte(5) ' measured angles to targets.
hit_index var nib ' number of targets found.
scan: ' perform a complete laser scan of the room
' and measure the angles to the target beacons.
lit=0: hit_index=0
low servo
for angle = cw_limit to ccw_limit step 5
pulsout servo, angle: pause 18: next ' rewind the sensor.
for angle = ccw_limit to cw_limit ' 360 degrees rotation.
pulsout servo,angle: pause 18 ' move the sensor.
high sensor: pause 1: rctime sensor,1,reflection
' debug ? reflection ' the sensor reading.
if (lit=0) or (reflection < threshold) then aaa
lit = 0
hit(hit_index)=(hit(hit_index)+((angle-ccw_limit)/4)/2)
hit_index=(hit_index+1) // 5: goto bbb
aaa: if (lit=1) or (reflection > thresholdh) then bbb
lit = 1: hit(hit_index)=(angle-ccw_limit)/4
bbb: next
low servo ' shut down the servo motor.
debug ? hit_index ' and show the results.
debug ? hit(0)
debug ? hit(1)
debug ? hit(2)
return
' End of the software